package com.atguigu.tingshu.payment.client;


import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.payment.service.WxPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/***
 * service-payment 内部调用接口
 * FeignClient --> PaymentFeignClient
 */
@RestController
@RequestMapping("/client/payment/wxPay")
public class WxPayClientController {

    @Autowired
    private WxPayService wxPayService;


    /**
     * 获取WeChatPay申请支付的url信息
     *
     * @param params
     * @@return
     */
    @GuiguLogin
    @GetMapping("/getPayInfoFromWx")
    public String getPayInfoFromWx(@RequestParam Map<String,String> params){
        return wxPayService.getPayInfoFromWx(params);
    }

    /**
     * 主动获取订单支付结果: 供商户调用 兜底方法
     * @param orderNo
     * @return
     */
    @GetMapping("/getOrderPayResult/{orderNo}")
    public String getOrderPayResult(@PathVariable("orderNo")String orderNo){
        return wxPayService.getOrderPayResult(orderNo);
    }


}
